<!--
    表格 => 数据 => 数组
    表单 => 数据 => 对象

    el-table : 表格组件
      - :data="tableData"  显示数据(数组)
    el-table-column : 表格列
      - label 当前列显示的标题文字
      - prop : 读取表格数据里的字段对应的值
    行数由表格数据(数组) 元素的个数决定
   -->
<div>
  <!-- 面包屑 -->
  <el-breadcrumb class="bread" separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    <el-breadcrumb-item>用户列表</el-breadcrumb-item>
  </el-breadcrumb>
  <!-- 输入框
    slot='append(后面) prepend(前面) '
    -->
  <el-row :gutter="20">
    <el-col :span="8">
      <el-input placeholder="请输入内容" v-model="searchText">
        <el-button
          @click="startQuery"
          slot="append"
          icon="el-icon-search"
        ></el-button>
      </el-input>
    </el-col>
    <el-col :span="8">
      <el-button @click="showAddUserDialog">添加用户</el-button>
    </el-col>
  </el-row>

  <!-- 表格 -->
  <el-table :data="usersData" style="width: 100%">
    <el-table-column prop="username" label="姓名" width="180">
    </el-table-column>
    <el-table-column prop="email" label="邮箱" width="180"> </el-table-column>
    <el-table-column prop="mobile" label="电话"> </el-table-column>
    <el-table-column label="状态"> </el-table-column>
    <el-table-column label="操作"> </el-table-column>
  </el-table>
  <!-- 分页
      total : 总个数
      page-size : 每页的个数
      current-page : 当前页数
    -->
  <el-pagination
    background
    layout="prev, pager, next"
    :total="total"
    :page-size="2"
    :current-page="pagenum"
    @current-change="changeCurPage"
  >
  </el-pagination>

  <!-- 第一个对话框 : 添加用户对话框 -->
  <!--
    el-dialog 对话框
   -->
  <el-dialog title="添加用户" :visible.sync="dialogAddUserVisible">
    <el-form :rules="rules" :model="addUserForm" label-width="80px">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="addUserForm.username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="addUserForm.password"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="addUserForm.email"></el-input>
      </el-form-item>
      <el-form-item label="手机" prop="mobile">
        <el-input v-model="addUserForm.mobile"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button @click="dialogAddUserVisible = false">取 消</el-button>
      <el-button type="primary" @click="addUser">确 定</el-button>
    </div>
  </el-dialog>
</div>
